<?php

	error_reporting(E_ALL & ~E_DEPRECATED);
	require_once("../db_connect.php");


	//会員登録

	$Family_Name  = htmlspecialchars($_POST['Family_Name'],ENT_QUOTES,"UTF-8");
	$Given_Name   = htmlspecialchars($_POST['Given_Name'],ENT_QUOTES,"UTF-8");
	$Family_Kana  = htmlspecialchars($_POST['Family_Kana'],ENT_QUOTES,"UTF-8");
	$Given_Kana   = htmlspecialchars($_POST['Given_Kana'],ENT_QUOTES,"UTF-8");

	$Nick_Name    = htmlspecialchars($_POST['Nick_Name'],ENT_QUOTES,"UTF-8");
	$Login_ID     = htmlspecialchars($_POST['Login_ID'],ENT_QUOTES,"UTF-8");
	$Password     = htmlspecialchars($_POST['Password'],ENT_QUOTES,"UTF-8");
	$K_Password   = htmlspecialchars($_POST['K_Password'],ENT_QUOTES,"UTF-8");

	$year         = date("Y-m-d",mktime(0,0,0,$_POST['month'],$_POST['day'],$_POST['year']));

	$Gender       = htmlspecialchars($_POST['Gender'],ENT_QUOTES,"UTF-8");
	$Position_ID  = htmlspecialchars($_POST['Position_ID'],ENT_QUOTES,"UTF-8");

	$Pref         = htmlspecialchars($_POST['Pref'],ENT_QUOTES,"UTF-8");
	$Phone_Number = htmlspecialchars($_POST['Phone_Number'],ENT_QUOTES,"UTF-8");
	$eMail        = htmlspecialchars($_POST['eMail'],ENT_QUOTES,"UTF-8");
	$K_eMail      = htmlspecialchars($_POST['K_eMail'],ENT_QUOTES,"UTF-8");

	$group_name	= htmlspecialchars($_POST['group_name'],ENT_QUOTES,"UTF-8");
	$group_kana	= htmlspecialchars($_POST['group_kana'],ENT_QUOTES,"UTF-8");
	$information	= htmlspecialchars($_POST['information'],ENT_QUOTES,"UTF-8");
	$url			= htmlspecialchars($_POST['url'],ENT_QUOTES,"UTF-8");
	$group_id		= htmlspecialchars($_POST['group_id'],ENT_QUOTES,"UTF-8");

	$sql = "INSERT INTO user(family_name,given_name,family_kana,given_kana,nick_name,login_id,password,birth_day,gender,post_id,pref,phone_number,email,group_name,group_kana,information,url,group_id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

	$stmt = $db->prepare($sql);

    $data = array($Family_Name,
                  $Given_Name,
                  $Family_Kana,
                  $Given_Kana,
                  $Nick_Name,
                  $Login_ID,
                  $Password,
                  $year,
                  $Gender,
                  $Position_ID,
                  $Pref,
                  $Phone_Number,
                  $eMail,
                  $group_name,
                  $group_kana,
                  $information,
                  $url,
                  $group_id
    );

	$db->execute($stmt, $data);     //UPDATE文を実行

	if (PEAR::isError($db)) {       //SQLの実行に失敗すればここでエラー文を出力
    	die($res->getMessage());
	}

	$_SESSION["user_name"] = $user_name;
	$_SESSION["user_id"] = $user_id;

	header("Location: ../top.php");
   ?>